import { Injectable } from '@nestjs/common';
import { SetKeyDao as Dao } from '@/servers/daos/common/set-key/set-key.dao';

@Injectable()
export class SetKeyService {

  constructor(private dao: Dao) { }

  /**
   * 通过type查询所有:组合查询条件
   */
  findAllByType(params: any): Promise<any> {
    const query = {
      where: {
        business_id: params.business_id,
        type: params.type,
        status: params.status,
      },
      order:{
        id:'ASC'
      },
      cache: {
        id: 'set_key_tenant_type_status',
        milisseconds: 25000,
      }
    };
    if(!params.status){
      delete query.where.status;
    }
    return this.dao.findAllByType(query);
  }

  /**
   * 查询所有
   */
  findAll(params: any): Promise<any> {
    return this.dao.findAll(params);
  }
  
  /**
   * 添加
   */
  add(params: any): Promise<any> {
    return this.dao.add(params);
  }

  /**
   * 修改
   * @param params
   */
  async update(params: any): Promise<any> {
    return this.dao.update(params);
  }

  /**
   * 删除
   * @param params
   */
  async delete(params: any): Promise<any> {
    return this.dao.delete(params);
  }

}
